﻿using System;
using System.Collections.Generic;
using System.Text;
using StockTrader.DAL.IDAL.HnxInfo;
using StockTrader.BusinessService.DataContract.HnxInfo;
using MySql.Data.MySqlClient;
using System.Data;
using StockTrader.DAL.MySQLHelper;

namespace StockTrader.DAL.MySQL.HnxInfo
{
    public class HnxOrders : IHnxOrders
    {
        private MySqlConnection _internalConnection;
        private MySqlTransaction _internalADOTransaction = null;

        public void Open(string connString)
        {
            if (_internalConnection == null)
                _internalConnection = new MySqlConnection(connString);
            if (_internalConnection.State != ConnectionState.Open)
                _internalConnection.Open();
        }
        public void Close()
        {
            if (_internalConnection != null && _internalConnection.State != System.Data.ConnectionState.Closed)
                _internalConnection.Close();
        }
        #region Parameters

        private const string PARM_ORDER_ID = "@ORDER_ID";
        private const string PARM_ORG_ORDER_ID = "@ORG_ORDER_ID";
        private const string PARM_FLOOR_CODE = "@FLOOR_CODE";
        private const string PARM_ORDER_CONFIRM_NO = "@ORDER_CONFIRM_NO";
        private const string PARM_ORDER_NO = "@ORDER_NO";
        private const string PARM_CO_ORDER_NO = "@CO_ORDER_NO";
        private const string PARM_ORG_ORDER_NO = "@ORG_ORDER_NO";

        private const string PARM_ORDER_DATE = "@ORDER_DATE";
        private const string PARM_ORDER_TIME = "@ORDER_TIME";
        private const string PARM_MEMBER_ID = "@MEMBER_ID";
        private const string PARM_ACCOUNT_ID = "@ACCOUNT_ID";
        private const string PARM_STOCK_ID = "@STOCK_ID";
        private const string PARM_ORDER_TYPE = "@ORDER_TYPE";
        private const string PARM_PRIORITY = "@PRIORITY";
        private const string PARM_ORDER_SIDE = "@ORDER_SIDE";
        private const string PARM_ORDER_CLASS = "@ORDER_CLASS";
        private const string PARM_MODIFIED_STATUS = "@MODIFIED_STATUS";
        private const string PARM_BORE = "@BORE";
        private const string PARM_AORI = "@AORI";
        private const string PARM_SETTLEMENT_TYPE = "@SETTLEMENT";
        private const string PARM_INVESTOR_TYPE = "@INVESTOR_TYPE";
        private const string PARM_ORDER_QTTY = "@ORDER_QTTY";
        private const string PARM_ORDER_PRICE = "@ORDER_PRICE";
        private const string PARM_STATUS = "@STATUS";
        private const string PARM_QUOTE_PRICE = "@QUOTE_PRICE";
        private const string PARM_QUOTE_TIME = "@QUOTE_TIME";
        private const string PARM_QUOTE_QTTY = "@QUOTE_QTTY";
        private const string PARM_ACCOUNT_NO = "@ACCOUNT_NO";
        private const string PARM_CO_ACCOUNT_NO = "@CO_ACCOUNT_NO";
        private const string PARM_BROKER_ID = "@BROKER_ID";
        private const string PARM_TELEPHONE = "@TELEPHONE";
        private const string PARM_SETTLE_DAY = "@SETTLE_DAY";
        private const string PARM_AORC = "@AORC";
        private const string PARM_YIELDMAT = "@YIELDMAT";
        private const string PARM_CODE_TRADE = "@CODE_TRADE";
        private const string PARM_STOCK_INFO_ID = "@STOCK_INFO_ID";
        private const string PARM_CODE = "@CODE";
        private const string PARM_STOCK_TYPE = "@STOCK_TYPE";
        private const string PARM_EXEC_QTTY = "@EXEC_QTTY";
        private const string PARM_CORRECT_QTTY = "@CORRECT_QTTY";
        private const string PARM_CANCEL_QTTY = "@CANCEL_QTTY";
        private const string PARM_TIMESTAMP = "@TIMESTAMP";

        #endregion

        #region SQL

        private const string INSERT_HNX_NEWORDER = "INSERT INTO HNX_ORDERS(ORDER_ID, ORG_ORDER_ID, FLOOR_CODE, ORDER_CONFIRM_NO, ORDER_NO, CO_ORDER_NO, ORG_ORDER_NO, ORDER_DATE, ORDER_TIME, MEMBER_ID, STOCK_ID, ORDER_TYPE, ORDER_SIDE, ORDER_CLASS, MODIFIED_STATUS , SETTLEMENT, INVESTOR_TYPE, ORDER_QTTY, ORDER_PRICE, STATUS, QUOTE_PRICE, QUOTE_QTTY, EXEC_QTTY, CORRECT_QTTY, CANCEL_QTTY, ACCOUNT_NO, CO_ACCOUNT_NO, BROKER_ID, TIMESTAMP) VALUES (@ORDER_ID, @ORG_ORDER_ID, @FLOOR_CODE, @ORDER_CONFIRM_NO, @ORDER_NO, @CO_ORDER_NO, @ORG_ORDER_NO, @ORDER_DATE, @ORDER_TIME, @MEMBER_ID, @STOCK_ID, @ORDER_TYPE, @ORDER_SIDE, @ORDER_CLASS, @MODIFIED_STATUS , @SETTLEMENT, @INVESTOR_TYPE, @ORDER_QTTY, @ORDER_PRICE, @STATUS, @QUOTE_PRICE, @QUOTE_QTTY, @EXEC_QTTY, @CORRECT_QTTY, @CANCEL_QTTY, @ACCOUNT_NO, @CO_ACCOUNT_NO, @BROKER_ID, @TIMESTAMP) ON DUPLICATE KEY UPDATE ORDER_ID=@ORDER_ID, ORDER_NO=@ORDER_NO, ORDER_DATE=@ORDER_DATE, ORDER_TIME=@ORDER_TIME, MEMBER_ID=@MEMBER_ID, STOCK_ID=@STOCK_ID, ORDER_TYPE=@ORDER_TYPE, ORDER_SIDE=@ORDER_SIDE, ORDER_CLASS=@ORDER_CLASS, MODIFIED_STATUS=@MODIFIED_STATUS , SETTLEMENT=@SETTLEMENT, INVESTOR_TYPE=@INVESTOR_TYPE, ORDER_QTTY=@ORDER_QTTY, ORDER_PRICE=@ORDER_PRICE, STATUS=@STATUS, QUOTE_PRICE=@QUOTE_PRICE, QUOTE_QTTY=@QUOTE_QTTY, EXEC_QTTY=@EXEC_QTTY, CORRECT_QTTY=@CORRECT_QTTY, CANCEL_QTTY=@CANCEL_QTTY, ACCOUNT_NO=@ACCOUNT_NO, BROKER_ID=@BROKER_ID, TIMESTAMP=@TIMESTAMP, CO_ORDER_NO=@CO_ORDER_NO, ORG_ORDER_NO=@ORG_ORDER_NO,ORG_ORDER_ID=@ORG_ORDER_ID, FLOOR_CODE=@FLOOR_CODE, ORDER_CONFIRM_NO=@ORDER_CONFIRM_NO, CO_ACCOUNT_NO=@CO_ACCOUNT_NO";

        private const string GET_HNX_ALLORDERS = "SELECT * FROM HNX_ORDERS WHERE ORDER_DATE=CURRENT_DATE";

        private const string GET_HNX_LASTORDERS = "SELECT * FROM HNX_ORDERS WHERE TIMESTAMP>@TIMESTAMP";

        private const string INSERT_HNX_NEWDEAL = "";

        private const string GET_ORDER_PLACE = "SELECT * FROM HNX_ORDERS WHERE MODIFIED_STATUS='NORMAL'";
        private const string GET_ORDER_MODIFY = "SELECT * FROM HNX_ORDERS WHERE MODIFIED_STATUS='CHANGE'";
        private const string GET_ORDER_CANCEL = "SELECT * FROM HNX_ORDERS WHERE MODIFIED_STATUS='CANCEL'";
        private const string GET_ORDER_MATCH = "SELECT * FROM HNX_ORDERS WHERE MODIFIED_STATUS='MATCH'";


        #endregion

        #region IHnxOrder Members

        public List<HnxOrdersData> getHnxNewOrders(decimal timeStamp)
        {
            throw new NotImplementedException();
        }

        public List<HnxOrdersData> getHnxAllOrders()
        {
            try
            {
                List<HnxOrdersData> list = new List<HnxOrdersData>();

                MySqlDataReader rdr = MyHelper.ExecuteReaderNoParm(_internalConnection, _internalADOTransaction, CommandType.Text, GET_HNX_ALLORDERS);

                while (rdr.Read())
                {
                    list.Add(new HnxOrdersData(
                                Convert.ToDecimal(rdr["ORDER_ID"]),
                                rdr["ORDER_NO"].ToString(),
                                Convert.ToDateTime(rdr["ORDER_DATE"]),
                                rdr["ORDER_TIME"].ToString(),
                                Convert.ToInt32(rdr["MEMBER_ID"]),
                                Convert.ToInt32(rdr["STOCK_ID"]),
                                rdr["ORDER_TYPE"].ToString(),
                                rdr["ORDER_SIDE"].ToString(),
                                rdr["ORDER_CLASS"].ToString(),
                                rdr["MODIFIED_STATUS"].ToString(),
                                Convert.ToInt32(rdr["SETTLEMENT"]),
                                rdr["INVESTOR_TYPE"].ToString(),
                                Convert.ToDecimal(rdr["ORDER_PRICE"]),
                                Convert.ToDecimal(rdr["ORDER_QTTY"]),
                                rdr["STATUS"].ToString(),
                                Convert.ToDecimal(rdr["QUOTE_PRICE"]),
                                Convert.ToDecimal(rdr["QUOTE_QTTY"]),
                                Convert.ToDecimal(rdr["EXEC_QTTY"]),
                                Convert.ToDecimal(rdr["CORRECT_QTTY"]),
                                Convert.ToDecimal(rdr["CANCEL_QTTY"]),
                                rdr["ACCOUNT_NO"].ToString(),
                                                                (rdr["CO_ACCOUNT_NO"] != DBNull.Value) ? rdr["CO_ACCOUNT_NO"].ToString() : string.Empty,

                                Convert.ToDecimal(rdr["BROKER_ID"]),
                                Convert.ToInt64(rdr["TIMESTAMP"])));
                }
                rdr.Close();
                return list;
            }
            catch (System.Exception e)
            {
                throw e;
            }
        }

        public List<HnxOrdersData> countHnxOrders()
        {
            throw new NotImplementedException();
        }

        public void deleteHnxOrders()
        {
            throw new NotImplementedException();
        }

        public void insertHnxNewOrder(HnxOrdersData order)
        {
            try
            {
                MySqlParameter[] parms = new MySqlParameter[] { 
                                     new MySqlParameter( PARM_ORDER_ID,MySqlDbType.Decimal),
                                     new MySqlParameter( PARM_ORG_ORDER_ID,MySqlDbType.Decimal),
                                     new MySqlParameter( PARM_FLOOR_CODE,MySqlDbType.VarChar),
                                     new MySqlParameter( PARM_ORDER_CONFIRM_NO,MySqlDbType.VarChar),
                                     new MySqlParameter( PARM_ORDER_NO,MySqlDbType.VarChar),
                                     new MySqlParameter( PARM_CO_ORDER_NO,MySqlDbType.VarChar),
                                     new MySqlParameter( PARM_ORG_ORDER_NO,MySqlDbType.VarChar),
                                     new MySqlParameter( PARM_ORDER_DATE,MySqlDbType.DateTime),
                                     new MySqlParameter( PARM_ORDER_TIME,MySqlDbType.VarChar),
                                     new MySqlParameter( PARM_MEMBER_ID,MySqlDbType.Int32),
                                     new MySqlParameter( PARM_STOCK_ID,MySqlDbType.Int32),
                                     new MySqlParameter( PARM_ORDER_TYPE,MySqlDbType.VarChar),
                                     new MySqlParameter( PARM_ORDER_SIDE,MySqlDbType.VarChar),
                                     new MySqlParameter( PARM_ORDER_CLASS,MySqlDbType.VarChar),
                                     new MySqlParameter( PARM_MODIFIED_STATUS,MySqlDbType.VarChar),
                                     new MySqlParameter( PARM_SETTLEMENT_TYPE,MySqlDbType.Int32),
                                     new MySqlParameter( PARM_INVESTOR_TYPE,MySqlDbType.VarChar),
                                     new MySqlParameter( PARM_ORDER_QTTY,MySqlDbType.Decimal),
                                     new MySqlParameter( PARM_ORDER_PRICE,MySqlDbType.Decimal),
                                     new MySqlParameter( PARM_STATUS,MySqlDbType.VarChar),
                                     new MySqlParameter( PARM_QUOTE_PRICE,MySqlDbType.Decimal),
                                     new MySqlParameter( PARM_QUOTE_QTTY,MySqlDbType.Decimal),
                                     new MySqlParameter( PARM_EXEC_QTTY,MySqlDbType.Decimal),
                                     new MySqlParameter( PARM_CORRECT_QTTY,MySqlDbType.Decimal),
                                     new MySqlParameter( PARM_CANCEL_QTTY,MySqlDbType.Decimal),
                                     new MySqlParameter( PARM_ACCOUNT_NO,MySqlDbType.VarChar),
                                     new MySqlParameter( PARM_CO_ACCOUNT_NO,MySqlDbType.VarChar),
                                     new MySqlParameter( PARM_BROKER_ID,MySqlDbType.Decimal),
                                     new MySqlParameter( PARM_TIMESTAMP,MySqlDbType.Int64)
                                 };

                parms[0].Value = order.OrderId;
                parms[1].Value = order.OrgOrderId;
                parms[2].Value = order.FloorCode;
                parms[3].Value = order.OrderConfirmNo;
                parms[4].Value = order.OrderNo;
                parms[5].Value = order.CoOrderNo;
                parms[6].Value = order.OrgOrderNo;
                parms[7].Value = order.OrderDate;
                parms[8].Value = order.OrderTime;
                parms[9].Value = order.MemberId;
                parms[10].Value = order.StockId;
                parms[11].Value = order.OrderType;
                parms[12].Value = order.OrderSide;
                parms[13].Value = order.OrderClass;
                parms[14].Value = order.ModifiedStatus;
                parms[15].Value = order.Settlement;
                parms[16].Value = order.InvestorType;
                parms[17].Value = order.OrderQtty;
                parms[18].Value = order.OrderPrice;
                parms[19].Value = order.Status;
                parms[20].Value = order.QuotePrice;
                parms[21].Value = order.QuoteQtty;
                parms[22].Value = order.ExecQtty;
                parms[23].Value = order.CorrectQtty;
                parms[24].Value = order.CancelQtty;
                parms[25].Value = order.AccountNo;
                parms[26].Value = order.CoAccountNo;
                parms[27].Value = order.BrokerId;
                parms[28].Value = order.TimeStamp;


                MyHelper.ExecuteNonQuery(_internalConnection, _internalADOTransaction, CommandType.Text, INSERT_HNX_NEWORDER, parms);
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }


        public List<HnxOrdersData> getLastHnxOrder(long timeStamp)
        {
            try
            {
                MySqlParameter parm1 = new MySqlParameter("@TIMESTAMP", MySqlDbType.Int64);
                parm1.Value = timeStamp;

                List<HnxOrdersData> list = new List<HnxOrdersData>();

                MySqlDataReader rdr = MyHelper.ExecuteReader(_internalConnection, _internalADOTransaction, CommandType.Text, GET_HNX_LASTORDERS, parm1);

                while (rdr.Read())
                {
                    list.Add(new HnxOrdersData(
                                Convert.ToDecimal(rdr["ORDER_ID"]),
                                rdr["ORDER_NO"].ToString(),
                                Convert.ToDateTime(rdr["ORDER_DATE"]),
                                rdr["ORDER_TIME"].ToString(),
                                Convert.ToInt32(rdr["MEMBER_ID"]),
                                Convert.ToInt32(rdr["STOCK_ID"]),
                                rdr["ORDER_TYPE"].ToString(),
                                rdr["ORDER_SIDE"].ToString(),
                                rdr["ORDER_CLASS"].ToString(),
                                rdr["MODIFIED_STATUS"].ToString(),
                                Convert.ToInt32(rdr["SETTLEMENT"]),
                                rdr["INVESTOR_TYPE"].ToString(),
                                Convert.ToDecimal(rdr["ORDER_PRICE"]),
                                Convert.ToDecimal(rdr["ORDER_QTTY"]),
                                rdr["STATUS"].ToString(),
                                Convert.ToDecimal(rdr["QUOTE_PRICE"]),
                                Convert.ToDecimal(rdr["QUOTE_QTTY"]),
                                Convert.ToDecimal(rdr["EXEC_QTTY"]),
                                Convert.ToDecimal(rdr["CORRECT_QTTY"]),
                                Convert.ToDecimal(rdr["CANCEL_QTTY"]),
                                rdr["ACCOUNT_NO"].ToString(),
                                rdr["ACCOUNT_NO"].ToString(),
                                Convert.ToDecimal(rdr["BROKER_ID"]),
                                Convert.ToInt64(rdr["TIMESTAMP"])));
                }
                rdr.Close();
                return list;
            }
            catch (System.Exception e)
            {
                throw e;
            }
        }



        public List<HnxOrdersData> getHnxPlaceOrder()
        {
            try
            {
                List<HnxOrdersData> list = new List<HnxOrdersData>();

                MySqlDataReader rdr = MyHelper.ExecuteReaderNoParm(_internalConnection, _internalADOTransaction, CommandType.Text, GET_ORDER_PLACE);

                while (rdr.Read())
                {
                    list.Add(new HnxOrdersData(
                                Convert.ToDecimal(rdr["ORDER_ID"]),
                                Convert.ToDecimal(rdr["ORG_ORDER_ID"]),
                                rdr["FLOOR_CODE"].ToString(),
                                rdr["ORDER_CONFIRM_NO"].ToString(),
                                rdr["ORDER_NO"].ToString(),
                                rdr["CO_ORDER_NO"].ToString(),
                                rdr["ORG_ORDER_NO"].ToString(),
                                Convert.ToDateTime(rdr["ORDER_DATE"]),
                                rdr["ORDER_TIME"].ToString(),
                                Convert.ToInt32(rdr["MEMBER_ID"]),
                                Convert.ToInt32(rdr["STOCK_ID"]),
                                rdr["ORDER_TYPE"].ToString(),
                                rdr["ORDER_SIDE"].ToString(),
                                rdr["ORDER_CLASS"].ToString(),
                                rdr["MODIFIED_STATUS"].ToString(),
                                Convert.ToInt32(rdr["SETTLEMENT"]),
                                rdr["INVESTOR_TYPE"].ToString(),
                                Convert.ToDecimal(rdr["ORDER_PRICE"]),
                                Convert.ToDecimal(rdr["ORDER_QTTY"]),
                                rdr["STATUS"].ToString(),
                                Convert.ToDecimal(rdr["QUOTE_PRICE"]),
                                Convert.ToDecimal(rdr["QUOTE_QTTY"]),
                                Convert.ToDecimal(rdr["EXEC_QTTY"]),
                                Convert.ToDecimal(rdr["CORRECT_QTTY"]),
                                Convert.ToDecimal(rdr["CANCEL_QTTY"]),
                                rdr["ACCOUNT_NO"].ToString(),
                                (rdr["CO_ACCOUNT_NO"] != DBNull.Value) ? rdr["CO_ACCOUNT_NO"].ToString() : string.Empty,
                                Convert.ToDecimal(rdr["BROKER_ID"])));
                }
                rdr.Close();
                return list;
            }
            catch (System.Exception e)
            {
                throw e;
            }
        }

        public List<HnxOrdersData> getHnxDeals()
        {
            try
            {
                List<HnxOrdersData> list = new List<HnxOrdersData>();

                MySqlDataReader rdr = MyHelper.ExecuteReaderNoParm(_internalConnection, _internalADOTransaction, CommandType.Text, GET_ORDER_MATCH);

                while (rdr.Read())
                {
                    list.Add(new HnxOrdersData(
                                Convert.ToDecimal(rdr["ORDER_ID"]),
                                Convert.ToDecimal(rdr["ORG_ORDER_ID"]),
                                rdr["FLOOR_CODE"].ToString(),
                                rdr["ORDER_CONFIRM_NO"].ToString(),
                                rdr["ORDER_NO"].ToString(),
                                rdr["CO_ORDER_NO"].ToString(),
                                rdr["ORG_ORDER_NO"].ToString(),
                                Convert.ToDateTime(rdr["ORDER_DATE"]),
                                rdr["ORDER_TIME"].ToString(),
                                Convert.ToInt32(rdr["MEMBER_ID"]),
                                Convert.ToInt32(rdr["STOCK_ID"]),
                                rdr["ORDER_TYPE"].ToString(),
                                rdr["ORDER_SIDE"].ToString(),
                                rdr["ORDER_CLASS"].ToString(),
                                rdr["MODIFIED_STATUS"].ToString(),
                                Convert.ToInt32(rdr["SETTLEMENT"]),
                                rdr["INVESTOR_TYPE"].ToString(),
                                Convert.ToDecimal(rdr["ORDER_PRICE"]),
                                Convert.ToDecimal(rdr["ORDER_QTTY"]),
                                rdr["STATUS"].ToString(),
                                Convert.ToDecimal(rdr["QUOTE_PRICE"]),
                                Convert.ToDecimal(rdr["QUOTE_QTTY"]),
                                Convert.ToDecimal(rdr["EXEC_QTTY"]),
                                Convert.ToDecimal(rdr["CORRECT_QTTY"]),
                                Convert.ToDecimal(rdr["CANCEL_QTTY"]),
                                rdr["ACCOUNT_NO"].ToString(),
                                (rdr["CO_ACCOUNT_NO"] != DBNull.Value) ? rdr["CO_ACCOUNT_NO"].ToString() : string.Empty,
                                Convert.ToDecimal(rdr["BROKER_ID"])));
                }
                rdr.Close();
                return list;
            }
            catch (System.Exception e)
            {
                throw e;
            }
        }

        public List<HnxOrdersData> getHnxChangeOrders()
        {
            try
            {
                List<HnxOrdersData> list = new List<HnxOrdersData>();

                MySqlDataReader rdr = MyHelper.ExecuteReaderNoParm(_internalConnection, _internalADOTransaction, CommandType.Text, GET_ORDER_MODIFY);

                while (rdr.Read())
                {
                    list.Add(new HnxOrdersData(
                                Convert.ToDecimal(rdr["ORDER_ID"]),
                                Convert.ToDecimal(rdr["ORG_ORDER_ID"]),
                                rdr["FLOOR_CODE"].ToString(),
                                rdr["ORDER_CONFIRM_NO"].ToString(),
                                rdr["ORDER_NO"].ToString(),
                                rdr["CO_ORDER_NO"].ToString(),
                                rdr["ORG_ORDER_NO"].ToString(),
                                Convert.ToDateTime(rdr["ORDER_DATE"]),
                                rdr["ORDER_TIME"].ToString(),
                                Convert.ToInt32(rdr["MEMBER_ID"]),
                                Convert.ToInt32(rdr["STOCK_ID"]),
                                rdr["ORDER_TYPE"].ToString(),
                                rdr["ORDER_SIDE"].ToString(),
                                rdr["ORDER_CLASS"].ToString(),
                                rdr["MODIFIED_STATUS"].ToString(),
                                Convert.ToInt32(rdr["SETTLEMENT"]),
                                rdr["INVESTOR_TYPE"].ToString(),
                                Convert.ToDecimal(rdr["ORDER_PRICE"]),
                                Convert.ToDecimal(rdr["ORDER_QTTY"]),                                
                                rdr["STATUS"].ToString(),
                                Convert.ToDecimal(rdr["QUOTE_PRICE"]),
                                Convert.ToDecimal(rdr["QUOTE_QTTY"]),
                                Convert.ToDecimal(rdr["EXEC_QTTY"]),
                                Convert.ToDecimal(rdr["CORRECT_QTTY"]),
                                Convert.ToDecimal(rdr["CANCEL_QTTY"]),
                                rdr["ACCOUNT_NO"].ToString(),
                                (rdr["CO_ACCOUNT_NO"] != DBNull.Value) ? rdr["CO_ACCOUNT_NO"].ToString() : string.Empty,
                                Convert.ToDecimal(rdr["BROKER_ID"])));
                }
                rdr.Close();
                return list;
            }
            catch (System.Exception e)
            {
                throw e;
            }
        }

        public List<HnxOrdersData> getHnxCancelOrders()
        {
            try
            {
                List<HnxOrdersData> list = new List<HnxOrdersData>();

                MySqlDataReader rdr = MyHelper.ExecuteReaderNoParm(_internalConnection, _internalADOTransaction, CommandType.Text, GET_ORDER_CANCEL);

                while (rdr.Read())
                {
                    list.Add(new HnxOrdersData(
                                Convert.ToDecimal(rdr["ORDER_ID"]),
                                Convert.ToDecimal(rdr["ORG_ORDER_ID"]),
                                rdr["FLOOR_CODE"].ToString(),
                                rdr["ORDER_CONFIRM_NO"].ToString(),
                                rdr["ORDER_NO"].ToString(),
                                rdr["CO_ORDER_NO"].ToString(),
                                rdr["ORG_ORDER_NO"].ToString(),
                                Convert.ToDateTime(rdr["ORDER_DATE"]),
                                rdr["ORDER_TIME"].ToString(),
                                Convert.ToInt32(rdr["MEMBER_ID"]),
                                Convert.ToInt32(rdr["STOCK_ID"]),
                                rdr["ORDER_TYPE"].ToString(),
                                rdr["ORDER_SIDE"].ToString(),
                                rdr["ORDER_CLASS"].ToString(),
                                rdr["MODIFIED_STATUS"].ToString(),
                                Convert.ToInt32(rdr["SETTLEMENT"]),
                                rdr["INVESTOR_TYPE"].ToString(),
                                Convert.ToDecimal(rdr["ORDER_PRICE"]),
                                Convert.ToDecimal(rdr["ORDER_QTTY"]),
                                rdr["STATUS"].ToString(),
                                Convert.ToDecimal(rdr["QUOTE_PRICE"]),
                                Convert.ToDecimal(rdr["QUOTE_QTTY"]),
                                Convert.ToDecimal(rdr["EXEC_QTTY"]),
                                Convert.ToDecimal(rdr["CORRECT_QTTY"]),
                                Convert.ToDecimal(rdr["CANCEL_QTTY"]),
                                rdr["ACCOUNT_NO"].ToString(),
                                (rdr["CO_ACCOUNT_NO"] != DBNull.Value) ? rdr["CO_ACCOUNT_NO"].ToString() : string.Empty,
                                Convert.ToDecimal(rdr["BROKER_ID"])));
                }
                rdr.Close();
                return list;
            }
            catch (System.Exception e)
            {
                throw e;
            }
        }

        #endregion
    }
}
